import { createElement, HTMLAttributes, type FC } from 'react';
import classNames from 'classnames';
import { tableBodyDefaultProps } from './defaultProps';
import type { TableBodyOptions } from './type';

export interface TableBodyProps extends TableBodyOptions, HTMLAttributes<HTMLTableSectionElement> {}

const TableBody: FC<TableBodyProps> = (props) => {
  const { className, children, forwardedRef, ...tableBodyProps } = props;

  return createElement('tbody', { ref: forwardedRef, className: classNames(className), ...tableBodyProps }, children);
};

TableBody.displayName = 'TableBody';
TableBody.defaultProps = tableBodyDefaultProps;

export default TableBody;
